Skip to main content

Iterating on data (for)

FOR is the primary construct used for iterating over a collection and its documents. You can use for to iterate over collections and apply filters or additional processing on the data

Basic for

  1. Here is an example of returning any 100 documents

    for flight in flights
    limit 100
    return flight
  2. Here is an example of deleting all the documents we created in the scratch collections (the return OLD returns the the deleted documents)

    for junk in scratch
    remove junk in scratch
    return OLD._key
  3. Running the AQL query again will return an empty list

    []
 
Help us improve

Anything unclear or buggy in this tutorial? Provide Feedback